﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.utils {
    import flash.utils.*;
    import net.wooga.pets.interfaces.*;

    public class DictStorage implements IStorage {

        private var _storage:Dictionary;
        private var _length:int;

        public function DictStorage(_arg1:Object=null, _arg2:Boolean=false){
            this.init(_arg1, _arg2);
        }
        public function init(_arg1:Object=null, _arg2:Boolean=false):void{
            var _local3:String;
            this._storage = new Dictionary(_arg2);
            this._length = 0;
            for (_local3 in _arg1) {
                this.set(_local3, _arg1[_local3]);
            };
        }
        public function set(_arg1, _arg2, _arg3:Boolean=true):void{
            var _local4:Boolean = this.has(_arg1);
            _arg3 = ((!(_local4)) || (_arg3));
            if (!_local4){
                this._length++;
            };
            if (_arg3){
                this._storage[_arg1] = _arg2;
            } else {
                throw (new Error((_arg1 + "was already set")));
            };
        }
        public function has(_arg1):Boolean{
            return (this._storage.hasOwnProperty(_arg1));
        }
        public function get(_arg1){
            return (this._storage[_arg1]);
        }
        public function remove(_arg1, _arg2=null){
            var _local3:* = this.get(_arg1);
            if (((this.has(_arg1)) && (delete this._storage[_arg1]))){
                this._length--;
            };
            return (_local3);
        }
        public function get storage(){
            return (this._storage);
        }
        public function get keys():Array{
            var _local2:String;
            var _local1:Array = [];
            for (_local2 in this._storage) {
                _local1.push(_local2);
            };
            return (_local1);
        }
        public function get values():Array{
            var _local2:Object;
            var _local1:Array = [];
            for each (_local2 in this._storage) {
                _local1.push(_local2);
            };
            return (_local1);
        }
        public function get isEmpty():Boolean{
            return ((this._length == 0));
        }
        public function get length():int{
            return (this._length);
        }

    }
}//package net.wooga.pets.utils 
